package com.jeff.android.lab.android.lazy;

import android.os.Bundle;

import androidx.viewpager.widget.ViewPager;

import com.jeff.android.lab.BaseActivity;
import com.jeff.android.lab.R;
import com.ogaclejapan.smarttablayout.SmartTabLayout;
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItem;
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter;
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems;

import butterknife.BindView;
import butterknife.ButterKnife;

public class LazyFragmentActivity extends BaseActivity {

    @BindView(R.id.tab) SmartTabLayout mTab;
    @BindView(R.id.view_pager) ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.android_activity_lazy_fragment);
        ButterKnife.bind(this);

        FragmentPagerItems pagerItems = new FragmentPagerItems(this);
        pagerItems.add(FragmentPagerItem.of("中国", FragmentA.class));
        pagerItems.add(FragmentPagerItem.of("德国", FragmentB.class));
        pagerItems.add(FragmentPagerItem.of("美国", FragmentC.class));

        FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pagerItems);
        mViewPager.setAdapter(adapter);
        mTab.setViewPager(mViewPager);
    }

}
